<?php

namespace App\Http\Controllers\Admin;

use League\OAuth2\Server\AuthorizationServer;
use Zend\Diactoros\Response as Psr7Response;
use League\OAuth2\Server\Exception\OAuthServerException;
use Psr\Http\Message\ServerRequestInterface;
use App\Http\Requests\Admin\AuthRequest;

class AuthController extends Controller
{
    public function store(AuthRequest $request, AuthorizationServer $server, ServerRequestInterface $serverRequest)
    {
        try {
            $authToken = $server->respondToAccessTokenRequest($serverRequest, new Psr7Response);
            return $authToken;
        } catch (OAuthServerException $e) {
            dump($e->getMessage());
        }
    }
}
